import {menulist} from "@/request/api.js"
export default {
    state:{
        menuList:[]
    },
    getters:{
        get_menuList(state){
            return state.menuList
        }
    },
    mutations:{
        mutation_menuList(state,payload){
            state.menuList = payload;
        }
    },
    actions:{
        //获取后端的菜单列表
        async action_menuList({commit}){
            try{
               let res = await menulist();
               if(res.code == 200){
                 //请求到数据后，更新数据
                 console.log(res);
                 commit("mutation_menuList",res.list);
               }
            }catch(err){
                console.log(err);
            }
        }
    },
    namespaced:true
}